package trefliq.EJB.entities;

import java.io.Serializable;
import javax.persistence.*;

/**
 *
 * @author Brandon
 */
@Entity
@NamedQueries ({
    @NamedQuery(name="findAllEmployees", query="SELECT e FROM Employee e"),
    @NamedQuery(name="findEmployeeById", query = "SELECT e FROM Employee e WHERE e.id = :id"),
    @NamedQuery(name="findEmployeeByPersonId", query="SELECT e from Employee e where e.personId = :personId"),
})
public class Employee implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
//    @NotNull
    @Column(name = "ID", nullable = false)
//    @GeneratedValue(strategy=GenerationType.TABLE, generator="EMPLOYEE")
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    
    /* FK - needs cardinality */ 
    private Long roleId; 
    
    /* FK - needs cardinality */ 
    private Long personId; 
    
    /* FK - needs cardinality */ 
    private Long credentialId; 
    
    public void Employee() { 
        
    }
    
    public void Employee(Long id) { 
        this.id = id; 
    }
    
    public void Employee(Long id, Long roleId, Long personId, Long credentialId) { 
        this.id = id; 
        this.roleId = roleId; 
        this.personId = personId; 
        this.credentialId = credentialId; 
    }
    
    public void Employee(Long roleId, Long personId, Long credentialId) { 
        this.roleId = roleId; 
        this.personId = personId; 
        this.credentialId = credentialId; 
    }
    
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getCredentialId() {
        return credentialId;
    }

    public void setCredentialId(Long credentialId) {
        this.credentialId = credentialId;
    }

    public Long getPersonId() {
        return personId;
    }

    public void setPersonId(Long personId) {
        this.personId = personId;
    }

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Employee other = (Employee) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 53 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }
   
    @Override
    public String toString() {
        return "trefliq.persistence.entity.Employee[ id=" + id + " ]";
    }
    
}
